home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 132_01 / ser69.a69 < prev    next >
Text File  |  1985-08-19  |  2KB  |  81 lines

  1. ;+
  2. ;    Serial Input routine for the 6809
  3. ;    I/O port configured for Radio Shack color computer
  4. ;-
  5. bitime    EQU    176H    ;Time constant for 1200 baud bit interval
  6. halfbit    EQU    29H    ; 1/2 bit time for center bit sync
  7. IPORT    EQU    0FF22H    ; Color computer i/o port address
  8. IMASK    EQU    1    ; Bit position of input bit in port
  9. ;
  10. ;+
  11. ;    input call to receive a character
  12. ;-
  13. serinp:
  14.     ORCC    50H    ;Kill interrupts
  15.     bsr    inwait        ;get character
  16.     clrb
  17.     EXG    B,A
  18.     rts            ;exit, character in b
  19. ;
  20. ;+
  21. ;    inwait    waits for an input character to start and
  22. ;    receives it.
  23. ;-
  24. inwait:
  25.     LDA    IPORT
  26.     ANDA    #IMASK            ; Get the bit out
  27.     beq    inwait        ; wait on line = 0 
  28. ;
  29. serget:
  30.     PSHS    X,Y,B
  31.     LDY    #8        ; Bit counter
  32.     LDX    #halfbit    ; Bit time/2
  33.     clra        ; clear receive register
  34. ;+
  35. ;    sync up on the start bit transition
  36. ;-
  37. sync:
  38.     LDB    IPORT    ;Get port value
  39.     ANDA    #IMASK        ;Test bit value
  40.     bne    sync        ;wait on start bit = 1
  41. start:
  42.     LEAX    -1,X
  43.     beq    assemble    ;one half bit time has expired
  44.     LDB    IPORT
  45.     ANDB    #IMASK
  46.     beq    start        ;count down the start bit
  47.     LDA    #-1        ; Glitch on start, return error
  48.     PULS    X,Y,B
  49.     rts            ;error exit
  50. assemble:
  51.     LDX    #bitime        ; Set one bit time wait
  52. assem1:
  53.     LEAX    -1,X        ;Decrement bit timer
  54.     bne    assem1
  55.     LDB    IPORT
  56.     ANDB    #IMASK
  57.     beq    assem2
  58.     ORA    #080H        ; Or in the bit
  59. assem2:
  60.     LEAY    -1,Y        ;Decrement the bit count
  61.     beq    seriox        ; exit if done
  62.     lsra        ; move the bit down for the next pass
  63.     bra    assemble
  64. seriox:
  65.     PULS    X,Y,B
  66.     rts            ; character in A
  67. 
  68.  
  69.  
  70.  
  71. cter in A
  72.  character in A
  73.  
  74.  in A
  75.  
  76.  
  77.  
  78. cter in A
  79.  
  80. racter in A
  81.  c